package org.example.domain;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.util.Date;

@Data
@TableName("comment")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Comment {

    public interface save{};

    @TableId("id")
    @Null(message = "评论ID必须为空",groups = {save.class})
    private Integer commentId;
    @NotNull(message = "评论内容不能为空",groups = {save.class})
    private String content;
    @Null(message = "评论时间必须为空",groups = {save.class})
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "create_time",fill = FieldFill.INSERT)
    private Date createTime;
    @NotNull(message = "评论用户ID不能为空",groups = {save.class})
    private int userId;
    @NotNull(message = "评论讨论ID不能为空",groups = {save.class})
    private int discussionId;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "update_time",fill = FieldFill.UPDATE)
    private Date updateTime;
}
